#include "../MsgServer.h"
#include "../MsgRequest.h"
#include "../MsgPublish.h"
#include <thread>
#include <chrono>
#include <iostream>
#include <stdio.h>

using namespace RobotControl::Common;

void stateSubCallback(zmq::message_t &data)
{
    std::string str((char *)data.data(), data.size());
    printf("sub len:%lld str: %s", data.size(), str.c_str());
}

void threadService(zmq::context_t *context)
{
	MsgServer m_server(context);
    m_server.addSubscriber("tcp://127.0.0.1:19001", std::bind(stateSubCallback, std::placeholders::_1));
    // m_server.addSubscriber("inproc://sub1", std::bind(sub1Callback, std::placeholders::_1));
	m_server.start();
	while(true){
		m_server.run();
	}
}

int main()
{
    zmq::context_t context(1);
    std::thread t0(threadService, &context);
    t0.join();
    return 0;
}

